#define DEBUG
#include <cstdio>
#define MAXN 100000

using namespace std;

long long min(long long a, long long b) {
  return a<b ? a : b;
}

long long max(long long a, long long b) {
  return a>b ? a : b;
}

class SegmentTree {
public:
  long long maxa[4*MAXN+1], size[4*MAXN+1], mark[4*MAXN+1];

  void init(int o, int l, int r) {
    mark[o]=1;
    if (l==r) {
      maxa[o] = size[o] = 1;
    } else {
      int mid=(l+r)/2;
      init(o*2, l, mid);
      init(o*2+1, mid+1, r);
      maxa[o] = max(maxa[o*2], maxa[o*2+1]);
      size[o] = size[o*2]+size[o*2+1];
    }
  }

  void markDown(int o, int l, int r) {
    if (mark[o]!=1) {
      maxa[o] *= mark[o];
      size[o] *= mark[o];
      if (l!=r) {
	mark[o*2]*=mark[o];
	mark[o*2+1]*=mark[o];
      }
      mark[o]=1;
    }
  }

  void twice(int o, int l, int r, long long tl, long long tr) {
    markDown(o, l, r);
    if (l==r) {
      maxa[o] += tr-tl+1L;
      size[o] += tr-tl+1L;
    } else if (tl==1 && tr==size[o]) {
      mark[o]*=2L;
      markDown(o, l, r);
    } else {
      int mid=(l+r)/2;
      markDown(o*2, l, mid);
      markDown(o*2+1, mid+1, r);
      int temp=size[o*2];
      if (tl<=temp) {
	twice(o*2, l, mid, tl, min(tr, temp));
      }
      if (tr>temp) {
	twice(o*2+1, mid+1, r, max(tl-temp, 1), tr-temp);
      }
      maxa[o] = max(maxa[o*2], maxa[o*2+1]);
      size[o] = size[o*2]+size[o*2+1];
    }
  }

  long long get(int o, int l, int r, long long tl, long long tr) {
    markDown(o, l, r);
    if (l==r) {
      return tr-tl+1;
    } else if (tl==1 && tr==size[o]) {
      return maxa[o];
    } else {
      int mid=(l+r)/2;
      long long ret=0;
      markDown(o*2, l, mid);
      markDown(o*2+1, mid+1, r);
      if (tl<=size[o*2] && tr>=1) {
	ret = max(ret, get(o*2, l, mid, tl, min(tr, size[o*2])));
      }
      if (tl<=size[o] && tr>size[o*2]) {
	ret = max(ret, get(o*2+1, mid+1, r, max(tl-size[o*2], 1), tr-size[o*2]));
      }
      return ret;
    }
  }
};

int main() {
#ifdef DEBUG
  freopen("2.in", "r", stdin);
  freopen("2.out", "w", stdout);
#endif

  static SegmentTree sgt;
  int n, m;
  scanf(" %d %d ", &n, &m);
  sgt.init(1, 1, n);
  for (int i=1; i<=m; i++) {
    char c;
    long long l, r;
    scanf(" %c %lld %lld ", &c, &l, &r);
    if (c=='Q') {
      printf("%lld\n", sgt.get(1, 1, n, l, r));
    } else {
      sgt.twice(1, 1, n, l, r);
    }
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
